package com.jueban.repository;

import com.jueban.model.user.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

public interface UserRepository extends CrudRepository<User, Integer> {
    User findByUsername(String name);

    Page<User> findAllByNameIsLikeAndIsRegistered(Pageable pageable, String name, Boolean isRegistered);

    @Query("select u from User as u where u.department like %:department% and u.username like %:username% and u.name like %:name%")
    Page<User> findAllByDepartmentAndUsernameAndName(@Param("pageable") Pageable pageable, @Param("department") String department, @Param("username") String username, @Param("name") String name);


}
